<template>
  <div>
    <van-nav-bar
        style="text-emphasis-color: burlywood"
        title="完善订单信息"
        left-text="返回"
        right-text="继续预定"
        left-arrow
        @click-left="back()"
        @click-right="tohous()"
    />
  </div>
  <div style="width: 100%;height: 50%">
    <van-image
        class="img1"
        :src="this.$route.query.imgurl"
    />
  </div>
  <van-progress pivot-text="" color="#ee0a24" :percentage="66" />
  <div v-for="a in server">
    <van-steps direction="vertical" >
      <van-step>
        <h4 style="margin-right: 250px">预定人姓名:</h4>
        <h4>{{a.peoplename}}</h4>
      </van-step>
      <van-step>
        <h4 style="margin-right: 250px">预定人数:</h4>
        <h4>{{a.mun}}人</h4>
      </van-step>
      <van-step>
        <h4 style="margin-right: 250px">手机号:</h4>
        <h4>{{a.phone}}</h4>
      </van-step>
      <van-step>
        <h4 style="margin-right: 250px">价格:</h4>
        <h4>{{a.housprice}}元</h4>
      </van-step>
      <van-step>
        <h4 style="margin-right: 250px">下单时间:</h4>
        <h4>{{a.ctime}}</h4>
      </van-step>
      <van-step>
        <h4 style="margin-right: 250px">状态:</h4>
        <h4 v-if="a.flag==1">未付款
          <van-button plain type="primary" size="small" color="red" style="float: right" @click="del(a.id)">删除订单</van-button>
          <van-button plain type="primary" size="small" color="blue" style="float: right" @click="returnPay()">去支付</van-button>
        </h4>
        <h4 v-else-if="a.flag==2" >已付款
          <van-button plain type="primary" size="small" color="black" style="float: right" @click="refund(a.idnum)">申请退款</van-button>
        </h4>
      </van-step>
    </van-steps>
    <van-progress pivot-text="" color="#ee0a24" :percentage="66" />
  </div>
</template>

<script>
export default {
  name: "PayServerView",
  data() {
    return{
      server:[
        {
            id:"",
            peoplename:"",
            mun:"",
            phone:"",
            idnum:"",
            housprice:"",
            token: "",
            flag:"",
        }
      ]
    }

  },mounted() {
      this.axios.get("/api/reserve/select.do?token="+this.$store.state.token).then(r=>{
      if(r.data.code==200){
        this.server=r.data.data;
      }else {
        this.$toast("没有订单哦！");
      }
    })

},methods:{
    back(){
      history.back();
    },returnPay(){
      this.$router.push({path:"/reserve",query:{imgurl:this.$route.query.imgurl}});
    },del(id){
      this.axios.post("/api/reserve/del.do?id="+id).then(r=>{
        if(r.data.code=200){
          this.$toast("删除成功");
          /*location.href="/payserver";*/
          /*this.$router.push("/payserver");*/
          this.$router.push({path:"/reserve",query:{imgurl:this.$route.query.imgurl}});
        }else {
          this.$toast(r.data.msg);
        }
      })
    },refund(idnum){
      this.axios.get("/api/houspay/refund.do?token="+this.$store.state.token+"&idnum="+idnum).then(r=>{
        if(r.data.code=200){
          this.$toast("退款成功");
          this.$router.push("/housinfo");
        }else {
          this.$toast(r.data.msg);
        }
      })
    },tohous(){
      this.$router.push("/housinfo");
    }
  }
}
</script>

<style scoped>

</style>